package com.zhixue.media.controller;

import com.zhixue.media.dto.*;
import com.zhixue.media.po.MediaFiles;
import com.zhixue.media.service.MediaFilesService;
import com.zhixue.model.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Auther: 李 力
 * @Date: 2025/4/14
 * @Description: com.zhixue.controller
 * @version: 1.0
 */
@RestController
@RequestMapping
public class MinioController {

    @Autowired
    private MediaFilesService mediaFilesService;

    //非视频文件
    @PostMapping(value = "/upload/coursefile", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public UploadFileResultDto upload(@RequestPart("filedata") MultipartFile filedata,
                                      @RequestParam(value = "objectName", required = false) String objectName
    ) {
        // todo 机构ID暂时写死
        Long companyId = 1L;
        return mediaFilesService.upload(filedata, companyId, objectName);
    }

    @PostMapping("/files")
    public PageResult<MediaFiles> selectPageList(PageParams pageParams, @RequestBody QueryMediaParamsDto paramsDto) {
        // todo 机构ID暂时写死
        Long companyId = 1L;
        return mediaFilesService.selectPageList(companyId, pageParams, paramsDto);
    }
}
